using UnityEngine;

public class MapScrolling : MonoBehaviour
{
    public Transform player;
    public float scrollSpeed = 5f;

    void Update()
    {
        if (player != null)
        {
            // Get the player's current position
            Vector3 playerPosition = player.position;

            // Calculate the target position for the camera to follow the player
            Vector3 targetPosition = new Vector3(playerPosition.x, transform.position.y, playerPosition.z);

            // Smoothly move the camera towards the target position
            transform.position = Vector3.Lerp(transform.position, targetPosition, scrollSpeed * Time.deltaTime);
        }
    }
}
